package com.fumihiko.modules.jxxm.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fumihiko.modules.jxxm.entity.OldWorkerErrorEntity;
import com.fumihiko.modules.jxxm.service.OldWorkerErrorService;
import com.fumihiko.common.utils.PageUtils;
import com.fumihiko.common.utils.R;



/**
 * VIEW
 *
 * @author hanwenpeng
 * @email devilzwy@gmail.com
 * @date 2022-04-14 15:53:26
 */
@RestController
@RequestMapping("jxxm/oldworkererror")
public class OldWorkerErrorController {
    @Autowired
    private OldWorkerErrorService oldWorkerErrorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("jxxm:oldworkererror:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = oldWorkerErrorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{name}")
    @RequiresPermissions("jxxm:oldworkererror:info")
    public R info(@PathVariable("name") String name){
		OldWorkerErrorEntity oldWorkerError = oldWorkerErrorService.getById(name);

        return R.ok().put("oldWorkerError", oldWorkerError);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("jxxm:oldworkererror:save")
    public R save(@RequestBody OldWorkerErrorEntity oldWorkerError){
		oldWorkerErrorService.save(oldWorkerError);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("jxxm:oldworkererror:update")
    public R update(@RequestBody OldWorkerErrorEntity oldWorkerError){
		oldWorkerErrorService.updateById(oldWorkerError);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("jxxm:oldworkererror:delete")
    public R delete(@RequestBody String[] names){
		oldWorkerErrorService.removeByIds(Arrays.asList(names));

        return R.ok();
    }

}
